<template>
  <view class="scrollbox">
    <u-navbar title="项目类型">
      <template #right>
        <!--  -->
        <view class="edtbtn" @click="onedt"> 添加 </view>
      </template>
    </u-navbar>
    <getdatascrollview ref="getdatascrollview" :api="api" :seardata="tablequery">
      <template #default="{ list }">
        <view class="searchcontent">
          <!-- <selectzitem
            v-model="searchdata.projectCode"
            :options="projectCodes"
            @change="change"
            :btnfalg="true"
          >
          </selectzitem> -->
          <view class="sx" @click="sxfn">
            筛选<u-icon name="arrow-down"></u-icon>
          </view>
        </view>
        <listcard v-for="item in list" :item="item" :list="listinputs" @click="ontap">

        </listcard>
      </template>
    </getdatascrollview>
    <sxpopup ref="sxpopup" :searchdata="searchdata"></sxpopup>
  </view>
</template>

<script>
import { getTypePage } from "@/api/appletManage/projectType.js";
export default {
  components: {},
  data() {
    return {
      projectCodes: [],
      customstyle: {
        margin: 0,
        flex: 0,
      },
      tablequery: {},
      api: getTypePage,
      searchdata: {},
      searchinputs: [
        {
          label: "类型编号",
          value: "typeCode",
        },
        {
          label: "类型名称",
          value: "typeName",
        },
      ],
      listinputs: [
        {
          label: "项目类型编号",
          value: "typeCode",
        },
        {
          label: "项目类型名称",
          value: "typeName",
        },
      ],
    };
  },
  onLoad() {
    this.init();
  },
  onShow() {
    this.$refs.getdatascrollview && this.$refs.getdatascrollview.onRefresh();
  },
  methods: {
    async init() { },
    change() {
      console.log("this.tablequery");
      this.onsearch();
    },
    sxfn() {
      this.$refs.sxpopup.open(this.searchinputs).then((data) => {
        this.searchdata = {
          ...this.searchdata,
          ...data,
        };
        this.onsearch();
      });
    },
    async onsearch() {
      this.tablequery = {
        ...this.searchdata,
      };

      this.$nextTick(() => {
        this.$refs.getdatascrollview.onRefresh();
      });
    },
    ondel(row) {
      console.log(row);
      uni.showModal({
        title: "提示",
        content: "是否删除此数据？",
        success: (res) => {
          if (res.confirm) {
            deleteCompanyFile([row.uuid]).then((e) => {
              this.onsearch();
            });
          } else if (res.cancel) {
            console.log("用户点击取消");
          }
        },
      });
    },
    onedt() {
      uni.navigateTo({
        url: "/pageswork/project/projectType/edit",
      });
    },
    ontap(item) {
      uni.navigateTo({
        url: `/pageswork/project/projectType/edit?id=${item.id}`,
      });
      //   console.log(item);
    },
  },
};
</script>
<style>
page {
  background: #fff;
}
</style>
<style lang="scss" scoped>
.edtbtn {
  color: #1890ff;
  font-size: 28rpx;
}

.searchcontent {
  display: flex;
  align-items: center;
  padding: 20rpx 20rpx 0 20rpx;

  .sx {
    padding-left: 20rpx;
    display: flex;
    font-size: 28rpx;
  }
}
</style>
